package io.gitee.cloudladder.obsidian.swagger2.example.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel(description = "response object for restful api")
public class Response<T> {

    @ApiModelProperty(value = "error code", name = "code", example = "1000001", allowableValues = "1000001, 1000002, 1000003", notes = "error code for restful api")
    int code;

    String message;

    T data;

    boolean success;

    public static <T> Response<T> success(T t) {
        Response<T> response = new Response<>();
        response.setSuccess(true);
        response.setCode(200);
        response.setMessage("ok");
        response.setData(t);
        return response;
    }

}
